package com.framework.web.bus.repository.specifications;

import com.framework.core.util.LikePatternUtil;
import com.framework.core.util.StringUtil;
import com.framework.web.bus.domain.GoodsInfo;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

/**
* @Title: Specs
* @Description: 分页查询
* @author laowang
* @date 2016-09-11
* @version V1.0
*
*/
public class GoodsInfoSpecs {

/**
* 分页查询
*
* @param  goodsInfo
* @return
*/
public static Specification<GoodsInfo> pageQueryGoodsInfo(
final GoodsInfo  goodsInfo) {

return new Specification<GoodsInfo>() {
@Override
public Predicate toPredicate(Root<GoodsInfo> root,
CriteriaQuery<?> query, CriteriaBuilder builder) {
    Predicate predicate = builder.and();
    // equal codeCategory
/*
    if (StringUtil.isNotEmpty( goodsInfo.getGoodsInfoType())) {
        predicate = builder.and(predicate, builder.like(
        builder.lower(root.<String>get(" goodsInfoType")),
        LikePatternUtil.getLikePattern( goodsInfo.getGoodsInfoType())));
    }
  */
        return predicate;
        }
    };
    }


    }
